package com.gxa.web_admin.controller.accesscontroller;

import com.gxa.common.R;
import com.gxa.modules.pojo.AlarmRules;
import com.gxa.modules.service.accessservice.AlarmRulesService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 告警规则
 */
@RestController
@RequestMapping(value = "alarmRules")
@Api(value = "告警规则模块",tags = "告警规则API")
public class AlarmRulesController {

    @Autowired
    private AlarmRulesService alarmRulesService;

    /**
     * 查询所有告警规则
     * @return 返回所有告警规则
     */
    @RequestMapping(value = "selecAalarmRules",method = RequestMethod.GET)
    @ApiOperation(value = "查询所有告警规则接口",notes = "根据传入信息查询告警规则",httpMethod = "GET", response = String.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "alarmRulesName",value = "告警名称",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "pushModeId",value = "推送方式id",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "page",value = "当前页码",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "size",value = "每页显示条数",paramType = "query",dataType = "String",required = true)
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R selecAalarmRules(String alarmRulesName,String pushModeId,String page,String size){
        return alarmRulesService.selecAalarmRules(alarmRulesName,pushModeId,page,size);
    }


    /**
     * 新增告警规则
     * @return 返回成功
     */
    @RequestMapping(value = "insertAalarmRules",method = RequestMethod.POST)
    @ApiOperation(value = "新增告警规则接口",notes = "新增告警规则",httpMethod = "POST", response = String.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R insertAalarmRules(@RequestBody @ApiParam(name = "insertAalarmRulesJson",
            value = "告警规则名称、告警规则、通知用户id、推送方式id、告警类型名称、告警等级、创建时间",required = true)
                                    AlarmRules alarmRules){

        return alarmRulesService.insertAalarmRules(alarmRules);
    }


    /**
     * 删除告警规则
     * @return 返回删除成功
     */
    @RequestMapping(value = "deleteAalarmRules",method = RequestMethod.POST)
    @ApiOperation(value = "删除告警规则接口",notes = "根据传入id删除告警规则",httpMethod = "POST", response = String.class)
    @ApiImplicitParam(name = "alarmRulesId",value = "告警规则id",paramType = "query",dataType = "String",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteAalarmRules(String alarmRulesId){

        return alarmRulesService.deleteAalarmRules(alarmRulesId);
    }

    /**
     * 修改告警规则
     * @return 返回成功
     */
    @RequestMapping(value = "updateAalarmRules",method = RequestMethod.POST)
    @ApiOperation(value = "修改告警规则接口",notes = "修改告警规则",httpMethod = "POST", response = String.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateAalarmRules(@RequestBody @ApiParam(name = "updateAalarmRulesJson",
            value = "告警规则id、告警规则名称、告警规则、通知用户id、推送方式id、告警类型名称、告警等级、修改时间",required = true)
                                       AlarmRules alarmRules){

        return alarmRulesService.updateAalarmRules(alarmRules);
    }

}
